using System;

namespace Extended.NetRouting
{
    public static class MemoryRouteProviderExtensions
    {
#if NET4
        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. 
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target, int length = 1, bool twoWay = false, string tag = null)
        {
            if (routeProvider == null) throw new ArgumentNullException("routeProvider");
            routeProvider.Add(new Route(start, target, length, tag));
            if (twoWay) routeProvider.Add(new Route(target, start, length, tag));
        }
#else
        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. Length is set to 1.
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target)
        {
            routeProvider.Add(new Route(start, target));
        }

        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. Length is set to 1.
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target, bool twoWay)
        {
            routeProvider.Add(new Route(start, target));
            routeProvider.Add(new Route(target, start));
        }

        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. 
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target, int length)
        {
            routeProvider.Add(new Route(start, target, length));
        }

        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. 
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target, int length, string tag)
        {
            routeProvider.Add(new Route(start, target, length, tag));
        }

        /// <summary>
        /// Adds a new <see cref="Route"/> to the route provider. 
        /// </summary>
        public static void Add(this MemoryRouteProvider routeProvider, object start, object target, int length, bool twoWay, string tag)
        {
            routeProvider.Add(new Route(start, target, length, tag));
            if (twoWay) routeProvider.Add(new Route(target, start, length, tag));
        }
#endif
    }
}